package com.ruoyi.apis.utils;

import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import org.apache.logging.log4j.util.Strings;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author Choi
 * @Date 2021/8/17
 */


public class ResponseUtils {

    public static String[] getImages(String image) {
        if (StringUtils.isNotEmpty(image)) {
            HttpServletRequest request = ServletUtils.getRequest();
            String domain = "https://" + request.getServerName();
            String[] images = image.split(",");
            for (int i = 0; i < images.length; i++) {
                images[i] = domain + images[i];
            }
            return images;
        } else {
            return new String[]{};
        }
    }

    public static String getFulImage(String image) {
        if (Strings.isBlank(image)) {
            return "";
        }
        HttpServletRequest request = ServletUtils.getRequest();
        String domain = "https://" + request.getServerName();
        return domain + image;
    }
}
